import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { UserWallet } from 'src/entities/UserWallet';
import { Repository } from 'typeorm';

@Injectable()
export class UserWalletService {
    constructor(
        @InjectRepository(UserWallet) protected repository:Repository<UserWallet>
    ){}

    async wallet(userId:number, fields:(keyof UserWallet)[] = ['amount', 'rewardAmount']) {
        return await this.repository.findOne({userId}, {
            select : fields
        })
    }
}